@section('title')
	创建律团 @parent
@show
@section('content')
<!-- Top Navbar-->
<div class="navbar theme-white">
	<div class="navbar-inner">
		<div class="left"><a href="{{ route('group.detail', $sns_group->id) }}" class="external link icon-only"> <i class="icon icon-back"></i></a></div>
		<div class="center sliding">律团资料</div>
		<div class="right">
				<a href="{{ route('group.index', $sns_group->id) }}" id="next-btn" class="link icon-only">进入</a>
		</div>
	</div>
</div>
<div class="pages navbar-through toolbar-through">
	<!-- Page, data-page contains page name-->
	<div data-page="creategroup" class="page pb60">
    <!-- Scrollable page content-->
    <div class="page-content">
     <div class="list-block">
        <ul>
          <li>
          <a href="{{ route('group.edititem', array($sns_group->id, 'avatar/group_avatar')) }}" class="item-link field-link">
            <div class="item-content">             
              <div class="item-inner"> 
                <div class="item-title label">律团头像</div>
                <div class="item-input">
                  @if ($sns_group->group_avatar )
                   <img src="{{ asset( $sns_group->group_avatar) }}" width="64" height="64">
                  @else
                    <img src="{{ asset('/img/group_avatar_index.jpg') }}" width="64" height="64">
                  @endif
                </div>
              </div>
            </div>
            </a>
          </li>
          <li>
          <a href="{{ route('group.edititem',array($sns_group->id, 'input/group_name')) }}" class="item-link field-link">
            <div class="item-content">
              
              <div class="item-inner"> 
                <div class="item-title label">律团名称</div>
                <div class="item-input">
                  {{ $sns_group->group_name }}
                </div>
              </div>
            </div>
          </a>
          </li>					
          <li>
            <a href="{{ route('group.edititem',array($sns_group->id, 'textarea/group_intro')) }}" class="item-link field-link">
            <div class="item-content">              
              <div class="item-inner"> 
                <div class="item-title label">律团简介</div>
                <div class="item-input">
                 {{ $sns_group->group_intro }}
                </div>
              </div>
            </div>
          </a>
          </li>
           <li>
            <a href="{{ route('group.edititem', array($sns_group->id, 'workscope/work_scope')) }}" class="item-link field-link">
            <div class="item-content">             
              <div class="item-inner"> 
                <div class="item-title label">业务范围</div>
                <div class="item-input">
                  {{ $sns_group->work_scope }}
                </div>
              </div>
            </div>
          </a>
          </li>
          <li>
             <a href="{{ route('group.edititem', array($sns_group->id, 'address/address')) }}" class="item-link field-link">
            <div class="item-content">
              <div class="item-inner"> 
                <div class="item-title label">律团地点</div>
                <div class="item-input">
                 {{ AreaHelper::areaCodeToName($sns_group->province) }} {{ AreaHelper::areaCodeToName($sns_group->city) }}
                </div>
              </div>
            </div>
          </a>
          </li>
        </ul>
      </div>
    </div>
  </div>
</div>
@include('widgets.toolbar', array('active'=>'sns'))
@stop
@section('bodyEnd')
{{ HTML::script('js/image.uploader.js') }}
<script>
  var uploader_init = false;
$$(document).on('click','input#captureFile', function(evt){
 var fileEle = this;
if ( !$$(this).hasClass('bind-evt') ) {
  ImageUploader.init({
    fileInputObj: fileEle,
    uploadVariableName : fileEle.name,
    fileUploadUrl: String('{{ route("group.upload_image", array($sns_group->id, ':field')) }}').replace(':field',fileEle.name),
    fileExtension:'jpg;gif;png;bmp',
    onSelect:function(event){
      myApp.showIndicator();
    },
    onFailure : function(event) {
      myApp.hideIndicator();
	  alert('错误代码'+event.errorCode);
	},
    onSuccess: function(event) {
      myApp.hideIndicator();
	  var na = this.uploadVariableName;
	  var obj = $$('#'+na+'_obj');
	  obj.val( event.target[0]['serverData'] );
	  $$('#'+na+'_perview').prop('src', event.target[0]['url']);
	  $$('#'+na+'_hids').append('<input type="hidden" name="'+na+'_his[]" value="'+event.target[0]['serverData']+'">');
	}
  });
  // ImageUploader._fileSelectEvent(evt);
  $$(this).addClass('bind-evt');
}
});

var area_data = {};
$$(document).on('pageInit', '.page[data-page="address"]', function (e) {
  $$(document).on('change','#field_province', function(){
	var val = $$(this).val();
	$$(this).attr('default','');
	$$('#field_city').html('');
	$$('#field_district').html('');
	var city_ele = $$('#field_city');
	var defval = '';
	if (val != '') {
	  defval = val.replace(/0000$/,'');
	}else{
	  return;
	}
	for (var key in area_data) {
	  var k = String(key);
	  if ( k.indexOf('00')==4 && k.indexOf(defval)===0 ) {
		var op = document.createElement('option');
		op.value = k, op.innerHTML = area_data[k];
		if ( $$('#field_city').attr('default') && $$('#field_city').attr('default') == k  ) {
		  op.selected = true;
		}
		city_ele.append(op);
	  }
	}
	city_ele.attr('default','')
	city_ele.trigger('change');
  });
   $$(document).on('change','#field_city', function(){
	var val = $$(this).val();
	$$(this).attr('default','');
	$$('#field_district').html('');
	if (val != '') {
	  defval = val.replace(/00$/,'');
	}else{
	  return;
	}
	var district_ele = $$('#field_district');
	for (var key in area_data) {
	  var k = String(key);
	  if ( k.indexOf(defval) === 0 && k.substr(-2)!='00' ) {
		var op = document.createElement('option');
		op.value = k, op.innerHTML = area_data[k];
		if ( $$('#field_district').attr('default') && $$('#field_district').attr('default') == k  ) {
		  op.selected = true;
		}
		district_ele.append(op);		
	  }
	}
	district_ele.attr('default','');
  });
	$$.getJSON("{{ route('common.area') }}", function (data){
	  area_data = data;
	  var province_ele = $$('#field_province');
	  for (var key in area_data) {
		var k = String(key);
		if ( k.indexOf('0000') == 2)  {
		  var op = document.createElement('option');
		  op.value = k, op.innerHTML = area_data[k];
		  if ( province_ele.attr('default') &&  province_ele.attr('default') == k ) {
			op.selected = true;
		  }
		  province_ele.append(op);
		}
		
	  }
	  if ( province_ele.attr('default')) {
		$$('#field_province').trigger('change');
	  }
	  
	});
});
</script>
@stop